<?php

use Illuminate\Routing\Router;
use App\Http\Controllers\Admin\User\LoginController;
use App\Http\Controllers\Admin\User\AdminController;
use App\Http\Controllers\Admin\User\PermissionController;

use App\Http\Controllers\Admin\Project\ProjectCateController;
use App\Http\Controllers\Admin\Project\ProjectController;
use App\Http\Controllers\Admin\Project\ProductController;

use App\Http\Controllers\Admin\Module\ModuleController;

use App\Http\Controllers\Admin\Env\HostEnvController;
use App\Http\Controllers\Admin\Env\HostController;
use App\Http\Controllers\Admin\Env\CommonHeaderController;

use App\Http\Controllers\Admin\Api\ApisValidatorController;
use App\Http\Controllers\Admin\Api\SampleValueController;

use App\Http\Controllers\Admin\Api\ApisController;
use App\Http\Controllers\Admin\Api\ApisHeaderController;
use App\Http\Controllers\Admin\Api\ApisParamController;


use App\Http\Controllers\Admin\RandomCheck\LogsController as RandomCheckLogs;
use App\Http\Controllers\Admin\RandomCheck\ModuleController as RandomCheckModule;
use App\Http\Controllers\Admin\RandomCheck\PointController as RandomCheckPoint;

use App\Http\Controllers\Admin\RunTest\RunTestController;
use App\Http\Controllers\Admin\RunTest\TestReportController;
use App\Http\Controllers\Admin\RunTest\TestModuleController;
use App\Http\Controllers\Admin\RunTest\TestApiController;
use App\Http\Controllers\Admin\RunTest\TestParamResController;
use App\Http\Controllers\Admin\RunTest\TestValidatorResController;



use App\Http\Controllers\Admin\Sundry\NotepadController;

Route::group(['middleware' => ['record.request']], function (Router $router) {
    $router->post('login', [LoginController::class, 'login'])->name('管理员登录');
    $router->post('oss-upload', [ProjectCateController::class, 'upload'])->name('图片上传oss');

    Route::group([
        "namespace" => 'User',
        "middleware" => ['admin.must']
    ], function (Router $router) {
        $router->post('adminer-menus', [LoginController::class, 'menus'])->name('管理员菜单');
        $router->post('admins', [AdminController::class, 'admins'])->name('管理员列表');
        $router->post('logout', [LoginController::class, 'logout'])->name('退出登录');

        $router->middleware('api.rate:add-admin,3')->post('add-admin', [AdminController::class, 'addAdmin'])->name('添加管理员');
        $router->post('del-admin', [AdminController::class, 'delAdmin'])->name('禁用管理员');
        $router->post('user-info', [AdminController::class, 'userInfo'])->name('管理员信息');
        $router->middleware('api.rate:reset-pwd,3')->post('reset-pwd', [AdminController::class, 'resetPwd'])->name('重置密码');

        $router->middleware('api.rate:role-edit,3')->post('role-edit',[PermissionController::class, 'editRole'])->name('角色添加编辑');
        $router->post('role-list', [PermissionController::class, 'roleList'])->name('角色列表');
        $router->post('menus-list', [PermissionController::class, 'menusList'])->name('权限菜单列表');
    });


    Route::group([
        "namespace" => 'Project',
        "middleware" => ['admin.must']
    ], function (Router $router) {
        $router->post('project-cate-list', [ProjectCateController::class, 'list'])->name('项目分类列表');
        $router->middleware('api.rate:project-cate-edit,3')->post('project-cate-edit', [ProjectCateController::class, 'edit'])->name('项目分类编辑/添加');
        $router->post('project-cate-enable', [ProjectCateController::class, 'enable'])->name('项目分类上下架');
        $router->post('project-cate-all', [ProjectCateController::class, 'allCate'])->name('项目分类all-list');

        $router->post('project-list', [ProjectController::class, 'list'])->name('项目列表');
        $router->middleware('api.rate:project-edit,3')->post('project-edit', [ProjectController::class, 'edit'])->name('项目编辑/添加');
        $router->post('project-enable', [ProjectController::class, 'enable'])->name('项目上下架');
        $router->post('project-all', [ProjectController::class, 'allProject'])->name('项目all-list');

        $router->post('product-list', [ProductController::class, 'list'])->name('产品列表');
        $router->middleware('api.rate:product-edit,3')->post('product-edit', [ProductController::class, 'edit'])->name('产品编辑/添加');
        $router->post('product-enable', [ProductController::class, 'enable'])->name('产品上下架');
        $router->post('product-all', [ProductController::class, 'allProduct'])->name('产品all-list');
    });

    Route::group([
        "namespace" => 'Module',
        "middleware" => ['admin.must']
    ], function (Router $router) {
        $router->post('module-list', [ModuleController::class, 'list'])->name('模块列表');
        $router->middleware('api.rate:module-edit,3')->post('module-edit', [ModuleController::class, 'edit'])->name('模块编辑/添加');
        $router->post('module-enable', [ModuleController::class, 'enable'])->name('模块上下架');
        $router->post('module-all', [ModuleController::class, 'allModule'])->name('模块all-list');
    });

    Route::group([
        "namespace" => 'Env',
        "middleware" => ['admin.must']
    ], function (Router $router) {
        $router->post('host-env-list', [HostEnvController::class, 'list'])->name('host环境标识列表');
        $router->middleware('api.rate:host-env-edit,3')->post('host-env-edit', [HostEnvController::class, 'edit'])->name('host环境标识编辑/添加');
        $router->post('host-env-enable', [HostEnvController::class, 'enable'])->name('host环境标识上下架');
        $router->post('host-env-all', [HostEnvController::class, 'allHostEnv'])->name('host环境标识host-env-all');

        $router->post('host-list', [HostController::class, 'list'])->name('host列表');
        $router->middleware('api.rate:host-edit,3')->post('host-edit', [HostController::class, 'edit'])->name('host编辑/添加');
        $router->post('host-enable', [HostController::class, 'enable'])->name('host上下架');
        $router->post('host-all', [HostController::class, 'allHost'])->name('host-env-all');

        $router->post('cheader-list', [CommonHeaderController::class, 'list'])->name('公共Header列表');
        $router->middleware('api.rate:cheader-edit,3')->post('cheader-edit', [CommonHeaderController::class, 'edit'])->name('公共Header编辑/添加');
        $router->post('cheader-enable', [CommonHeaderController::class, 'enable'])->name('公共Header上下架');
        $router->post('cheader-all', [CommonHeaderController::class, 'allCommonHeader'])->name('公共Header-all');
    });

    Route::group([
        "namespace" => 'Api',
        "middleware" => ['admin.must']
    ], function (Router $router) {
        $router->post('api-list', [ApisController::class, 'list'])->name('接口列表');
        $router->middleware('api.rate:api-edit,3')->post('api-edit', [ApisController::class, 'edit'])->name('接口编辑/添加');
        $router->post('api-enable', [ApisController::class, 'enable'])->name('接口上下架');
        $router->post('api-all', [ApisController::class, 'allApis'])->name('api-all');

        $router->post('header-list', [ApisHeaderController::class, 'list'])->name('host列表');
        $router->middleware('api.rate:header-edit,3')->post('header-edit', [ApisHeaderController::class, 'edit'])->name('host编辑/添加');
        $router->post('header-enable', [ApisHeaderController::class, 'enable'])->name('host上下架');

        $router->post('param-list', [ApisParamController::class, 'list'])->name('参数列表');
        $router->middleware('api.rate:param-edit,3')->post('param-edit', [ApisParamController::class, 'edit'])->name('参数编辑/添加');
        $router->post('param-enable', [ApisParamController::class, 'enable'])->name('参数删除');
        $router->middleware('api.rate:param-view-res,3')->post('param-view-res', [ApisParamController::class, 'viewRes'])->name('查看结果');

        $router->post('sample-value-list', [SampleValueController::class, 'list'])->name('取样器列表');
        $router->middleware('api.rate:sample-value-edit,3')->post('sample-value-edit', [SampleValueController::class, 'edit'])->name('取样器编辑/添加');
        $router->post('sample-value-enable', [SampleValueController::class, 'enable'])->name('取样器删除');
        $router->middleware('api.rate:more-sample-values,3')->post('more-sample-values', [SampleValueController::class, 'moreSampleValues'])->name('提前批量取样');

        $router->post('validator-list', [ApisValidatorController::class, 'list'])->name('验证器列表');
        $router->middleware('api.rate:validator-edit,3')->post('validator-edit', [ApisValidatorController::class, 'edit'])->name('验证器编辑/添加');
        $router->post('validator-enable', [ApisValidatorController::class, 'enable'])->name('验证器删除');
    });

    Route::group([
        "namespace" => 'RandomCheck',
        "middleware" => ['admin.must']
    ], function (Router $router) {
        $router->post('random-check-logs', [RandomCheckLogs::class, 'list'])->name('巡检列表');
        $router->middleware('api.rate:logs-check-edit,3')->post('random-check-edit', [RandomCheckLogs::class, 'edit'])->name('巡检编辑');

        $router->post('random-check-module-list', [RandomCheckModule::class, 'list'])->name('巡检模块列表');
        $router->middleware('api.rate:random-check-module-edit,3')->post('random-check-module-edit', [RandomCheckModule::class, 'edit'])->name('巡检模块编辑');
        $router->post('random-check-module-all', [RandomCheckModule::class, 'allModules'])->name('巡检模块all');

        $router->post('random-check-point-list', [RandomCheckPoint::class, 'list'])->name('巡检要点列表');
        $router->middleware('api.rate:random-check-point-edit,3')->post('random-check-point-edit', [RandomCheckPoint::class, 'edit'])->name('巡检要点编辑');
    });

    Route::group([
        "namespace" => 'RunTest',
        "middleware" => ['admin.must']
    ], function (Router $router) {
        $router->middleware('api.rate:make-report,4')->post('make-report', [RunTestController::class, 'makeReport'])->name('生成测试单');
        $router->middleware('api.rate:make-report,4')->post('run-report', [RunTestController::class, 'runTest'])->name('执行测试单');

        $router->post('report-list', [TestReportController::class, 'list'])->name('测试单列表');
        $router->post('test-module-list', [TestModuleController::class, 'list'])->name('测试模块列表');
        $router->post('test-apis-list', [TestApiController::class, 'list'])->name('测试接口列表');
        $router->post('test-param-list', [TestParamResController::class, 'list'])->name('测试用例列表');
        $router->post('test-validator-list', [TestValidatorResController::class, 'list'])->name('测试验证器列表');
    });

    Route::group([
        "namespace" => 'Sundry',
        "middleware" => ['admin.must']
    ], function (Router $router) {
        $router->post('notepad-list', [NotepadController::class, 'list'])->name('笔记列表');
        $router->middleware('api.rate:notepad-edit,6')->post('notepad-edit', [NotepadController::class, 'edit'])->name('笔记编辑/添加');
        $router->post('notepad-enable', [NotepadController::class, 'enable'])->name('笔记修改状态');
    });
});
